package com;

import java.security.SecureRandom;

/**
 * @BelongsProject: study
 * @BelongsPackage: com
 * @Author: zhangzhanheng
 * @CreateTime: 2024-07-17  09:58
 * @Description: TODO
 * @Version: 1.0
 */
public class UniqueStringGenerator {
    private static final String CHAR_LOWER = "abcdefghijklmnopqrstuvwxyz";
    private static final String CHAR_UPPER = CHAR_LOWER.toUpperCase();
    private static final String NUMBER = "0123456789";
    private static final String SPECIAL_CHARS = "!@#$%^&*";
    private static final String DATA_FOR_RANDOM_STRING = CHAR_LOWER + CHAR_UPPER + NUMBER + SPECIAL_CHARS;
    private static final SecureRandom random = new SecureRandom();

    public static void main(String[] args) {
        for (int i = 0; i < 3; i++) {
            System.out.println(generateRandomString(32));
        }
    }

    public static String generateRandomString(int length) {
        StringBuilder sb = new StringBuilder(length);
        for (int i = 0; i < length; i++) {
            int index = random.nextInt(DATA_FOR_RANDOM_STRING.length());
            sb.append(DATA_FOR_RANDOM_STRING.charAt(index));
        }
        return sb.toString();
    }
}
